#include<cstdio>
using  namespace std;
const int MAN=2e5+5;
int N,sum,flag=-1,t;
int a[MAN];
int vis[MAN],next[MAN];
int main(){
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	scanf("%d",&N);
	for(int i=1;i<=N;i++) scanf("%d",&a[i]);
	for(int i=N;i>=1;i--){
		if(a[i]!=flag){
			t=i;
			flag=a[i];
			next[i]=i+1;
		}
		else next[i]=t;
	}
	while(sum<N){
		flag=-1;
		int i=1; 
		while(i<=N){
			if(!vis[i]&&a[i]!=flag){
				printf("%d ",i);
				flag=a[i];
				vis[i]=1;
				sum++;
				i=next[i];
			}
			else i++;
		}
		printf("\n");
	}
	return 0;
}
